package com.interaction.qualitytimeaiagent.rag;

import org.springframework.ai.chat.client.advisor.RetrievalAugmentationAdvisor;
import org.springframework.ai.chat.client.advisor.api.Advisor;
import org.springframework.ai.rag.retrieval.search.DocumentRetriever;
import org.springframework.ai.rag.retrieval.search.VectorStoreDocumentRetriever;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.ai.vectorstore.filter.Filter;
import org.springframework.ai.vectorstore.filter.FilterExpressionBuilder;

/**
 * 检索增强顾问工厂
 */
public class QualityTimeRagCustomAdvisorFactory {

    public static Advisor createQueryTimeRagCustomerAdvisor(VectorStore vectorStore,String status){
        Filter.Expression expression = new FilterExpressionBuilder().eq("status", status).build();
        DocumentRetriever retriever = VectorStoreDocumentRetriever.builder().vectorStore(vectorStore).filterExpression(expression)
                .similarityThreshold(0.5)
                .topK(3).build();
        return RetrievalAugmentationAdvisor.builder().documentRetriever(retriever)
                .queryAugmenter(QualityTimeContextualQueryAugmenterFactory.createInstance())
                .build();
    }
}
